home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
role
/
roleplay.0-s
/
roleplay
/
RolePlaying-1.0
/
scripts
/
CHARFunctions
next >
Wrap
Text File
|
1995-07-09
|
13KB
|
362 lines
# Module: CHARFunctions
# Tcl version: 7.3 (Tcl/Tk/XF)
# Tk version: 3.6
# XF version: $__lastrelease$
#
# module contents
global moduleList
global autoLoadList
set moduleList(CHARFunctions) { AdvanceCharacterLevel .top10 ReRollCharacter ResetCharacterForm RollCharacter RollCharacterCancel RollCharacterHelp RollCharacterOk UpdateCharacter}
set autoLoadList(CHARFunctions) {1}
# procedures to show toplevel windows
# procedure to show window ShowWindow.top10
proc ShowWindow.top10 { args} {
# xf ignore me 7
# build widget .top10
if {"[info procs XFEdit]" != ""} {
catch "XFDestroy .top10"
} {
catch "destroy .top10"
}
toplevel .top10
# Window manager configurations
global tkVersion
wm positionfrom .top10 ""
wm sizefrom .top10 ""
wm maxsize .top10 1000 768
wm minsize .top10 10 10
wm title .top10 {Roll A New Character}
# build widget .top10.frame0
frame .top10.frame0 -borderwidth {2}
# build widget .top10.frame0.entry1
entry .top10.frame0.entry1 -relief {sunken} -width {1}
# build widget .top10.frame0.entry3
entry .top10.frame0.entry3 -relief {sunken} -width {1}
# build widget .top10.frame0.entry4
entry .top10.frame0.entry4 -relief {sunken} -width {1}
# build widget .top10.frame0.entry5
entry .top10.frame0.entry5 -relief {sunken} -width {3}
# build widget .top10.frame0.entry6
entry .top10.frame0.entry6 -relief {sunken} -width {1}
# build widget .top10.frame0.entry8
entry .top10.frame0.entry8 -relief {sunken} -width {3}
# build widget .top10.frame0.label0
label .top10.frame0.label0 -text {Hit Dice:}
# build widget .top10.frame0.label1
label .top10.frame0.label1 -text {Max Hit Dice:}
# build widget .top10.frame0.label2
label .top10.frame0.label2 -text {d}
# build widget .top10.frame0.label3
label .top10.frame0.label3 -text {Abitity Dice:}
# build widget .top10.frame0.label5
label .top10.frame0.label5 -text {d}
# build widget .top10.frame0.label7
label .top10.frame0.label7 -text {Best of:}
# pack widget .top10.frame0
pack append .top10.frame0 .top10.frame0.label3 {left frame center} .top10.frame0.entry4 {left frame center} .top10.frame0.label5 {left frame center} .top10.frame0.entry6 {left frame center} .top10.frame0.label0 {left frame e expand} .top10.frame0.entry1 {left frame center} .top10.frame0.label2 {left frame center} .top10.frame0.entry3 {left frame center} .top10.frame0.label7 {left frame e expand} .top10.frame0.entry8 {left frame e} .top10.frame0.label1 {left frame center} .top10.frame0.entry5 {left frame center}
# build widget .top10.frame13
frame .top10.frame13 -borderwidth {2}
# build widget .top10.frame13.label14
label .top10.frame13.label14 -text {S:}
# build widget .top10.frame13.label15
label .top10.frame13.label15 -relief {sunken} -text {} -width {5}
# build widget .top10.frame13.label16
label .top10.frame13.label16 -text {I:}
# build widget .top10.frame13.label17
label .top10.frame13.label17 -relief {sunken} -text {} -width {5}
# build widget .top10.frame13.label18
label .top10.frame13.label18 -text {W:}
# build widget .top10.frame13.label19
label .top10.frame13.label19 -relief {sunken} -text {} -width {5}
# build widget .top10.frame13.label20
label .top10.frame13.label20 -text {D:}
# build widget .top10.frame13.label21
label .top10.frame13.label21 -relief {sunken} -text {} -width {5}
# build widget .top10.frame13.label22
label .top10.frame13.label22 -text {C:}
# build widget .top10.frame13.label23
label .top10.frame13.label23 -relief {sunken} -text {} -width {5}
# build widget .top10.frame13.label24
label .top10.frame13.label24 -text {CH:}
# build widget .top10.frame13.label25
label .top10.frame13.label25 -relief {sunken} -text {} -width {5}
# pack widget .top10.frame13
pack append .top10.frame13 .top10.frame13.label14 {left frame center expand} .top10.frame13.label15 {left frame center expand} .top10.frame13.label16 {left frame center expand} .top10.frame13.label17 {left frame center expand} .top10.frame13.label18 {left frame center expand} .top10.frame13.label19 {left frame center expand} .top10.frame13.label20 {left frame center expand} .top10.frame13.label21 {left frame center expand} .top10.frame13.label22 {left frame center expand} .top10.frame13.label23 {left frame center expand} .top10.frame13.label24 {left frame center expand} .top10.frame13.label25 {right frame center expand}
# build widget .top10.frame28
frame .top10.frame28 -borderwidth {2}
# build widget .top10.frame28.button29
button .top10.frame28.button29 -command {ReRollCharacter} -text {ReRoll}
# build widget .top10.frame28.button30
button .top10.frame28.button30 -command {RollCharacterOk} -text {Ok}
# build widget .top10.frame28.button31
button .top10.frame28.button31 -command {RollCharacterCancel} -text {Cancel}
# build widget .top10.frame28.button32
button .top10.frame28.button32 -command {RollCharacterHelp} -text {Help}
# pack widget .top10.frame28
pack append .top10.frame28 .top10.frame28.button29 {left frame center expand} .top10.frame28.button30 {left frame center expand} .top10.frame28.button31 {left frame center expand} .top10.frame28.button32 {right frame center expand}
# build widget .top10.label12
label .top10.label12 -font {-Adobe-Helvetica-Bold-R-Normal--*-240-*} -text {Rolling A New Character}
# pack widget .top10
pack append .top10 .top10.label12 {top frame center} .top10.frame0 {top frame center expand fillx} .top10.frame13 {top frame center} .top10.frame28 {top frame center expand fillx}
if {"[info procs XFEdit]" != ""} {
XFEditSetShowWindows
XFMiscBindWidgetTree .top10
}
.top10.frame0.entry1 insert end {1}
.top10.frame0.entry3 insert end {6}
.top10.frame0.entry4 insert end {3}
.top10.frame0.entry5 insert end {10}
.top10.frame0.entry6 insert end {6}
.top10.frame0.entry8 insert end {10}
}
proc DestroyWindow.top10 {} {# xf ignore me 7
if {"[info procs XFEdit]" != ""} {
if {"[info commands .top10]" != ""} {
global xfShowWindow.top10
set xfShowWindow.top10 0
XFEditSetPath .
after 200 "XFSaveAsProc .top10; XFEditSetShowWindows"
}
} {
catch "destroy .top10"
update
}
}
# User defined procedures
# Procedure: AdvanceCharacterLevel
proc AdvanceCharacterLevel {} {
global CurrentCharacter
if {$CurrentCharacter(handle) != {}} {
UpdateCharacter
$CurrentCharacter(handle) advancelevel
set CurrentCharacter(isdirty) 1
ResetCharacterForm
}
}
# Procedure: ReRollCharacter
proc ReRollCharacter {} {
set sides [[SN RollNSides] get]
set dice [[SN RollNDice] get]
set bestof [[SN RollBestOf] get]
set abilityDice [Dice $sides $dice]
set best(strength) 0
set best(intelligence) 0
set best(wisdom) 0
set best(dexterity) 0
set best(constitution) 0
set best(chrisma) 0
for {set i 0} {$i < $bestof} {incr i} {
foreach a {strength intelligence wisdom dexterity constitution chrisma} {
set current($a) [$abilityDice roll]
}
set isbetter 0
foreach a {strength intelligence wisdom dexterity constitution chrisma} {
if {$current($a) > $best($a)} {
incr isbetter
}
}
if {$isbetter > 3} {
foreach a {strength intelligence wisdom dexterity constitution chrisma} {
set best($a) $current($a)
}
}
}
[SN RollStrength] configure -text [format "%d" $best(strength)]
[SN RollIntelligence] configure -text [format "%d" $best(intelligence)]
[SN RollWisdom] configure -text [format "%d" $best(wisdom)]
[SN RollDexterity] configure -text [format "%d" $best(dexterity)]
[SN RollConstitution] configure -text [format "%d" $best(constitution)]
[SN RollChrisma] configure -text [format "%d" $best(chrisma)]
$abilityDice delete
}
# Procedure: ResetCharacterForm
proc ResetCharacterForm {} {
global CurrentCharacter
[SN CharacterAge] delete 0 end
[SN CharacterAlignment] delete 0 end
[SN CharacterChrisma] delete 0 end
[SN CharacterClass] delete 0 end
[SN CharacterConstitution] delete 0 end
[SN CharacterDexterity] delete 0 end
[SN CharacterExperiencePoints] delete 0 end
[SN CharacterIntelligence] delete 0 end
[SN CharacterName] delete 0 end
[SN CharacterPlayer] delete 0 end
[SN CharacterRace] delete 0 end
[SN CharacterSex] delete 0 end
[SN CharacterStrength] delete 0 end
[SN CharacterEStrength] delete 0 end
[SN CharacterWisdom] delete 0 end
[SN CharacterCommentary] delete 1.0 end
[SN CharacterLevel] configure -text {}
[SN CharacterHitPoints] configure -text {}
if {$CurrentCharacter(handle) != {}} {
[SN CharacterAge] insert end [$CurrentCharacter(handle) age]
[SN CharacterAlignment] insert end [$CurrentCharacter(handle) alignment]
[SN CharacterChrisma] insert end [$CurrentCharacter(handle) chrisma]
[SN CharacterClass] insert end [$CurrentCharacter(handle) class]
[SN CharacterConstitution] insert end [$CurrentCharacter(handle) constitution]
[SN CharacterDexterity] insert end [$CurrentCharacter(handle) dexterity]
[SN CharacterExperiencePoints] insert end [$CurrentCharacter(handle) experiencepoints]
[SN CharacterIntelligence] insert end [$CurrentCharacter(handle) intelligence]
[SN CharacterName] insert end [$CurrentCharacter(handle) name]
[SN CharacterPlayer] insert end [$CurrentCharacter(handle) player]
[SN CharacterRace] insert end [$CurrentCharacter(handle) race]
[SN CharacterSex] insert end [$CurrentCharacter(handle) sex]
[SN CharacterStrength] insert end [$CurrentCharacter(handle) strength]
set es [$CurrentCharacter(handle) exceptional_strength]
if {$es != 0} {
if {$es == 100} {
[SN CharacterEStrength] insert end {(00)}
} else {
[SN CharacterEStrength] insert end [format "(%02d)" $es]
}
}
[SN CharacterWisdom] insert end [$CurrentCharacter(handle) wisdom]
[SN CharacterCommentary] insert end [$CurrentCharacter(handle) comments]
[SN CharacterLevel] configure -text [$CurrentCharacter(handle) level]
[SN CharacterHitPoints] configure -text [$CurrentCharacter(handle) hitpoints]
}
}
# Procedure: RollCharacter
proc RollCharacter {} {
ShowWindow[SN RollCharacter]
ReRollCharacter
update idletask
grab [SN RollCharacter]
tkwait window [SN RollCharacter]
global RollResults
if {$RollResults(button) != {ok}} {
return {}
} else {
return [list $RollResults(strength) $RollResults(intelligence) $RollResults(wisdom) $RollResults(dexterity) $RollResults(constitution) $RollResults(chrisma) $RollResults(nhitd) $RollResults(hitds) $RollResults(maxdie)]
}
}
# Procedure: RollCharacterCancel
proc RollCharacterCancel {} {
global RollResults
set RollResults(button) {cancel}
DestroyWindow[SN RollCharacter]
}
# Procedure: RollCharacterHelp
proc RollCharacterHelp {} {
PopupHelpTopic RollCharacter
}
# Procedure: RollCharacterOk
proc RollCharacterOk {} {
global RollResults
set RollResults(strength) [lindex [[SN RollStrength] configure -text] 4]
set RollResults(intelligence) [lindex [[SN RollIntelligence] configure -text] 4]
set RollResults(wisdom) [lindex [[SN RollWisdom] configure -text] 4]
set RollResults(dexterity) [lindex [[SN RollDexterity] configure -text] 4]
set RollResults(constitution) [lindex [[SN RollConstitution] configure -text] 4]
set RollResults(chrisma) [lindex [[SN RollChrisma] configure -text] 4]
set RollResults(nhitd) [[SN RollNHitDice] get]
set RollResults(hitds) [[SN RollHitDiceSides] get]
set RollResults(maxdie) [[SN RollMaxHitDice] get]
set RollResults(button) {ok}
DestroyWindow[SN RollCharacter]
}
# Procedure: UpdateCharacter
proc UpdateCharacter {} {
global CurrentCharacter
if {$CurrentCharacter(handle) != {}} {
$CurrentCharacter(handle) age [[SN CharacterAge] get]
$CurrentCharacter(handle) alignment [[SN CharacterAlignment] get]
$CurrentCharacter(handle) chrisma [[SN CharacterChrisma] get]
$CurrentCharacter(handle) class [[SN CharacterClass] get]
$CurrentCharacter(handle) constitution [[SN CharacterConstitution] get]
$CurrentCharacter(handle) dexterity [[SN CharacterDexterity] get]
$CurrentCharacter(handle) experiencepoints [[SN CharacterExperiencePoints] get]
$CurrentCharacter(handle) intelligence [[SN CharacterIntelligence] get]
$CurrentCharacter(handle) name [[SN CharacterName] get]
$CurrentCharacter(handle) player [[SN CharacterPlayer] get]
$CurrentCharacter(handle) race [[SN CharacterRace] get]
$CurrentCharacter(handle) sex [[SN CharacterSex] get]
$CurrentCharacter(handle) strength [[SN CharacterStrength] get]
set es [[SN CharacterEStrength] get]
set esv 0
if {[scan $es "(%02d)" esv] == 0} {
$CurrentCharacter(handle) exceptional_strength 0
} elseif {$esv == 0} {
$CurrentCharacter(handle) exceptional_strength 100
} else {
$CurrentCharacter(handle) exceptional_strength $esv
}
$CurrentCharacter(handle) wisdom [[SN CharacterWisdom] get]
$CurrentCharacter(handle) comments [[SN CharacterCommentary] get 1.0 end]
set CurrentCharacter(isdirty) 1
}
}
# Internal procedures
# eof
#